﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CateList.aspx.cs" Inherits="Crm_CateList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="crm.css" rel="stylesheet" type="text/css" />    
</head>
<body>
    <form id="form1" runat="server">   
    
    <div style="padding:0 5px;"><div class="nav">当前位置：产品分类</div><div style="margin-bottom:5px;"><asp:Button ID="btnAddNew" runat="server" Text="新建分类" onclick="btnAddNew_Click" /></div>
      <asp:GridView ID="gvList" runat="server" AutoGenerateColumns="False"
        DataSourceID="AccessDataSource1" DataKeyNames="id" AllowPaging="True" AllowSorting="True">
        <Columns>      
          <asp:BoundField DataField="id" HeaderText="目录代号" ReadOnly="false" Visible="false"
                    SortExpression="id" />                
            <asp:BoundField DataField="cateid" HeaderText="编号" 
                 SortExpression="cateid"/>
            <asp:BoundField DataField="cate_name" HeaderText="分类名称" 
                SortExpression="cate_name" />
            <asp:BoundField DataField="px" HeaderText="排序" 
                SortExpression="px" />
            <asp:BoundField DataField="jb" HeaderText="级别" 
                SortExpression="jb" />
              <%--  <asp:TemplateField>
                <ItemTemplate><a href="catelist2.aspx?pid=<%#Eval("id") %>&jb=1">管理子分类</a></ItemTemplate>
                </asp:TemplateField>--%>
                 <asp:CommandField  ShowEditButton="True" />
                   <asp:TemplateField ShowHeader="False">
                    <ItemTemplate>
                        <asp:LinkButton ID="LinkButton1" OnClientClick="return confirm('确认要删除吗？');" runat="server"
                            CausesValidation="False" CommandName="Delete" Text="删除"></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
        </Columns>
    </asp:GridView>
    </div>
    
    
    
 <%--   <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:strWeb %>" 
        SelectCommand="SELECT cateid as id,* FROM ProductCate WHERE ([jb] = @jb and pid=@pid ) ORDER BY [px] DESC" 
        DeleteCommand="DELETE FROM ProductCate WHERE ([cateid] = @id or pid=@id)"        
        
        UpdateCommand="UPDATE ProductCate SET [cate_name] = @cate_name, [px] = @px, [jb] = @jb WHERE [cateid] = @id">
        <SelectParameters>
            <asp:Parameter DefaultValue="0" Name="jb" Type="Int32" />
            <asp:Parameter DefaultValue="0" Name="pid" Type="Int32" />
        </SelectParameters>
        <DeleteParameters>
            <asp:Parameter Name="id" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="cate_name" Type="String" />
            <asp:Parameter Name="px" Type="Int32" />
            <asp:Parameter Name="jb" Type="Int32" />
            <asp:Parameter Name="id" Type="Int32" />      
        </UpdateParameters>       
    </asp:SqlDataSource>--%>
    <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/flashcrm.mdb" DeleteCommand="DELETE FROM [ProductCate] WHERE [cateId] = ?" InsertCommand="INSERT INTO [ProductCate] ([cateId], [cate_name], [pid], [px], [jb]) VALUES (?, ?, ?, ?, ?)" SelectCommand="SELECT cateid as id,cateid,* FROM [ProductCate]" UpdateCommand="UPDATE [ProductCate] SET [cate_name] = ?, [pid] = ?, [px] = ?, [jb] = ? WHERE [cateId] = ?">
        <DeleteParameters>
            <asp:Parameter Name="cateId" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="cate_name" Type="String" />
            <asp:Parameter Name="pid" Type="Int32" />
            <asp:Parameter Name="px" Type="Int32" />
            <asp:Parameter Name="jb" Type="Int32" />
            <asp:Parameter Name="cateId" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="cateId" Type="Int32" />
            <asp:Parameter Name="cate_name" Type="String" />
            <asp:Parameter Name="pid" Type="Int32" />
            <asp:Parameter Name="px" Type="Int32" />
            <asp:Parameter Name="jb" Type="Int32" />
        </InsertParameters>
    </asp:AccessDataSource>
    </form>
</body>
</html>
